{% extends "base.html" %}

{% block content %}
    <h2 class="mb-4">{% if is_update %}编辑文章{% else %}发布新文章{% endif %}</h2>
    <div class="row">
        <div class="col-md-8">
            <form method="POST">
                <div class="mb-3">
                    <label for="title" class="form-label">文章标题</label>
                    <input type="text" class="form-control" id="title" name="title" 
                           value="{{ post.title if post else '' }}" required>
                </div>
                <div class="mb-3">
                    <label for="content" class="form-label">文章内容</label>
                    <textarea class="form-control" id="content" name="content" rows="10" required>
                        {{ post.content if post else '' }}
                    </textarea>
                </div>
                <button type="submit" class="btn btn-primary">
                    {% if is_update %}更新文章{% else %}发布文章{% endif %}
                </button>
                {% if is_update %}
                    <a href="{{ url_for('post', post_id=post.id) }}" class="btn btn-secondary ms-2">取消</a>
                {% else %}
                    <a href="{{ url_for('home') }}" class="btn btn-secondary ms-2">取消</a>
                {% endif %}
            </form>
        </div>
    </div>
{% endblock %}
